import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

let originPush = VueRouter.prototype.push
let originReplace = VueRouter.prototype.replace
 
VueRouter.prototype.push = function push(location){
  return originPush.call(this,location).catch(err=>err)
}
VueRouter.prototype.replace = function push(location){
  return originReplace.call(this,location).catch(err=>err)
}
import login from '../components/login.vue'
import homepage from '../components/homepage.vue'
import center from '../components/PersonalCenter.vue'
import index from '../components/index.vue'
import bake from '../components/bake.vue'
import welding from '../components/welding.vue'
import detection from '@/components/detection.vue'
import alarmhistory from '@/components/alarmhistory.vue'
import cleaned_alarmhistory from '@/components/cleaned_alarmhistory.vue'
const route=new VueRouter({
    mode:"history",
    routes:[
        //将初始路径改为login
        // {
        //     path:'*',
        //     redirect:'/login'
        // },
        // //映射login组件，到login路径
        // {
        //     path:'/login',
        //     component:login
        // },
        {
            path:'/',
            component:login
        },
        //home组件，到home路径
        {
            path:'/monitor',
            component:homepage,
            children:[
                {
                    path:'/center',
                    component:center
                },
                {
                    path:'/index',
                    component:index,
                },
                {
                    path:'/bake',
                    component:bake,
                },
                {
                    path:'/welding',
                    component:welding,
                },
                {
                    path:'/detection',
                    component:detection,
                },
                {
                    path:'/alarmhistory',
                    component:alarmhistory,
                },
                {
                    path:'/alarmhistory1',
                    component:cleaned_alarmhistory,
                }
            ]
        },
        
    ]
})

export default route

